<%@page pageEncoding = "utf-8" contentType = "text/html;charset=utf-8"%>

<%@taglib prefix = "c" uri = "http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix = "fmt" uri = "http://java.sun.com/jsp/jstl/fmt"%>
<%@taglib prefix = "fn" uri = "http://java.sun.com/jsp/jstl/functions"%>

<h2><fmt:message key = "form.TaskDetails"/></h2>

<div class = "messages"><jsp:include page = "/messages.jsp"/></div>           

<p>
<c:if test = "${(sessionScope.role == 'leadexecutor' && status == 'request_lead_executor') 
  || sessionScope.role == 'chief'}"
>
<c:if test = "${taskBean.status.id != 3}">
<a href = "${sessionScope.alias}?_action=editTaskForm&task_id=${taskBean.id}&request_id=${taskBean.requestId}">
  Изменить  
</a>
</c:if>
</c:if>

<a href = "${sessionScope.alias}?_action=requestDetails&request_id=${taskBean.requestId}">
  <fmt:message key = "form.RequestDetails"/>
</a>
</p>

<table class = "form" cellpadding="8" style="width: 100%;">
   <tr style="background-color: #FAFAFA; border-bottom:1px solid #F1F1F1; border-top:1px solid #F1F1F1;">
      <td class = "label" style="width: 130px;"><fmt:message key = "task.id"/></td>
      <td>${taskBean.id}</td>
   </tr>
   
   <tr>
      <td class="label">Название</td>
      <td>
        <c:choose>
            <c:when test="${taskBean.name == null}">
              <span style="color: red;">нет данных</span>
            </c:when>
            <c:otherwise>
              <c:out value="${taskBean.name}"/>
            </c:otherwise>
        </c:choose>        
      </td>
   </tr>
   
   <tr style="background-color: #FAFAFA; border-bottom:1px solid #F1F1F1; border-top:1px solid #F1F1F1;">
      <td class = "label">Исполнитель</td>
      <td>
        <c:out value = "${taskBean.executor.lastName} ${taskBean.executor.firstName} ${taskBean.executor.middleName}"/> 
        (<a href="mailto:${taskBean.executor.email}">${taskBean.executor.email}</a>)
      </td>
   </tr>  

   <tr>
      <td class = "label"><fmt:message key = "task.status"/></td>
      <td>
        <c:out value = "${taskBean.status.status}"/>
        &nbsp;
        <c:if test = "${taskBean.status.id != 3}">
          <a href = "${sessionScope.alias}?_action=setTaskCompleated&task_id=${taskBean.id}">
            Завершить
          </a>
          
          <c:if 
            test = 
            "${(sessionScope.role == 'leadexecutor' && status == 'request_lead_executor') 
            || sessionScope.role == 'chief'}"
          >
          
          <c:if test = "${taskBean.status.id != 2}">
          <a href = "${sessionScope.alias}?_action=setTaskInactive&task_id=${taskBean.id}">
            Приостановить
          </a>      
          </c:if>
          
          <c:if test = "${taskBean.status.id == 2}">        
            <a href = "${sessionScope.alias}?_action=setTaskActive&task_id=${taskBean.id}">
              Возобновить выполнение
            </a>      
          </c:if>
          
          </c:if>
        </c:if>        
      </td>
   </tr> 

   <tr style="background-color: #FAFAFA; border-bottom:1px solid #F1F1F1; border-top:1px solid #F1F1F1;">
      <td class = "label"><fmt:message key = "task.priority"/></td>
      <td>         
         <c:forEach var = "i" begin = "1" end = "${taskBean.priority}">
            <img src = "images/priority_item${i}.gif">
         </c:forEach>
         ${taskBean.priorityBean.value}
      </td>
   </tr>
      
   <tr>
      <td class = "label"><fmt:message key = "task.text"/></td>
      <td class = "textField"><c:out value = "${taskBean.text}"/></td>
   </tr>                  
      
   <tr style="background-color: #FAFAFA; border-bottom:1px solid #F1F1F1; border-top:1px solid #F1F1F1;">
      <td class = "label"><fmt:message key = "task.startdate"/></td>
      <td><fmt:formatDate value="${taskBean.startDate}" pattern="dd.MM.yyyy"/></td>
   </tr>
      
   <tr>
      <td class = "label">Завершить к</td>
      <td><fmt:formatDate value="${taskBean.approxEndDate}" pattern="dd.MM.yyyy"/></td>
   </tr>

   <tr style="background-color: #FAFAFA; border-bottom:1px solid #F1F1F1; border-top:1px solid #F1F1F1;">
      <td class = "label"><fmt:message key = "task.enddate"/></td>
      <td>
        <c:choose>
            <c:when test="${taskBean.endDate == null}">
              <span style="color: red;">нет данных</span>
            </c:when>
            <c:otherwise>
              <fmt:formatDate value="${taskBean.endDate}" pattern="dd.MM.yyyy"/>
            </c:otherwise>
         </c:choose>        
      </td>
   </tr>

   <tr>
      <td class = "label"><fmt:message key = "task.report"/></td>
      <td class="textField">
        <c:if test="${taskBean.status.id == 1 || taskBean.status.id == 2}">
        <a class = "control" href = "${sessionScope.alias}?_action=taskReportForm&task_id=${taskBean.id}&request_id=${taskBean.requestId}">
           <fmt:message key = "Command.writeReport"/>
        </a>
        </c:if>
        <p>
          <c:choose>
            <c:when test="${taskBean.executorReport == null}">
              <span style="color: red;">нет данных</span>
            </c:when>
            <c:otherwise>
              <c:out value = "${taskBean.executorReport}"/>
            </c:otherwise>
          </c:choose>          
        </p>
      </td>
   </tr>
</table>

<p>
<c:if test = "${(sessionScope.role == 'leadexecutor' && status == 'request_lead_executor') 
  || sessionScope.role == 'chief'}"
>
<c:if test = "${taskBean.status.id != 3}">
<a href = "${sessionScope.alias}?_action=editTaskForm&task_id=${taskBean.id}&request_id=${taskBean.requestId}">
  Изменить  
</a>
</c:if>
</c:if>

<a href = "${sessionScope.alias}?_action=requestDetails&request_id=${taskBean.requestId}">
  <fmt:message key = "form.RequestDetails"/>
</a>
</p>